package com.kedeng.yangmuyi.dao;

import org.hibernate.HibernateException;
import org.springframework.stereotype.Repository;

import com.kedeng.yangmuyi.dto.UserProfileDTO;
import com.kedeng.yangmuyi.exception.SystemException;
import com.kedeng.yangmuyi.model.ProfileDO;

/**
 * 
 * @ClassName: UserProfileDAO
 * @Description: Operate with profile data.
 * @author rqian
 * @date Jul 3, 2013 4:11:22 PM
 * 
 */
@Repository
public class UserProfileDAO extends BaseDAOImpl {

    public ProfileDO queryUserProfileByLoginData(String loginEmail, String loginPasswdWithMD5) {
        String hql = "from ProfileDO p where p.email = \'" + loginEmail + "\' and p.passwordWithMD5 = \'"
                + loginPasswdWithMD5+"\'";
        return (ProfileDO) loadObject(hql);
    }



    public void insertProfile(UserProfileDTO profile) {
        try {
            save(profile);
        } catch (SystemException e) {
            throw new HibernateException("Insert profile to database failed.",e);
        }
    }



    public UserProfileDTO queryUserProfile(String username) {
        // TODO Auto-generated method stub
        return null;
    }

}
